﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Authorization/ServiceCollectionExtensions 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       ServiceCollectionExtensions
* 创建时间：  2025/5/24 10:44:26
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using SSPivot.AspNetCore.Abstractions.User;
using SSPivot.Authorization.Security;
using SSPivot.Authorization.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Authorization
{
    /// <summary>
    /// 权限认证扩展
    /// </summary>
    public static class AuthorizationServiceCollectionExtensions
    {
        /// <summary>
        /// 添加数据上下文
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddAuthorizationPermissions(this IServiceCollection services)
        {
            services.AddAuthorizationCore();
            services.AddTransient<ICurrentUser, CurrentUser>(); 
            services.AddSingleton<ICurrentPrincipalAccessor, HttpContextCurrentPrincipalAccessor>();
            return services;
        }
    }
}
